package com.example.iot.dao.impl;

import com.example.iot.dao.RuleChainDao;
import com.example.iot.entity.id.RuleChainId;
import com.example.iot.entity.po.RuleChainPO;
import com.example.iot.mapper.mysql.RuleChainMapper;
import com.example.iot.dao.BaseDaoImpl;
import org.springframework.stereotype.Service;

import java.util.Objects;
import java.util.Optional;

/**
 * @author ChenXiangpeng
 */
@Service
public class RuleChainDaoImpl extends BaseDaoImpl<RuleChainMapper, RuleChainPO> implements RuleChainDao {
    @Override
    public Optional<RuleChainPO> findRuleChainById(RuleChainId ruleChainId) {
        RuleChainPO ruleChain = this.baseMapper.selectById(ruleChainId.getIdStr());
        return Objects.isNull(ruleChain) ? Optional.empty() : Optional.of(ruleChain);
    }
}
